<?php
class Mozg_Module_Instance extends Mozg_Env_Base
{
    public function __construct ($protName, $envName)
    {
    	parent::__construct($protName, $envName);
    	
    	list(,,$name) = explode('_', get_class($this));
        $this->SetName($name);

        Mozg_Lang::Required('module_' .$this->GetName());
    }

    final private function SetName($name)
    {
        $this->_name = strtolower($name);
        return $this;
    }
    
    final public function GetName()
    {
        return $this->_name;
    }

    final public function GetId()
    {
        return Mozg_Module::GetId($this->GetName());
    }

    final public function GetPath ()
    {
        return Mozg_Module::GetPath($this->GetName());
    }
    
    public function GetCtrl($ctrlName)
    {
    	return Mozg::Ctrl($this->GetName(), $ctrlName, $this->GetProt(), $this->GetEnv());
    }
    
    /**
		Инициализация модуля
     */
    public function Init ()
    {

    }
    
    public function CheckAccessWithUserGranted(Mozg_Controller_Instance $ctrlObj, $basicActionName)
    {
		return $ctrlObj->CheckAccessWithUserGranted($basicActionName);
    }

	/**
	 * авторизация юзера
	 *
	 */
    public function Auth()
    {
        return $this;
    }

}